package javax;

public class Xp_0106 {
    //获取最大值、递归实现
    public static int getMax(int[] arr, int left ,int right){
        if (left == right){
            return arr[left];
        }
        //中间位置
        int mid = (right + left)/2;
        int leftmax = getMax(arr,left,mid);
        int rightMax = getMax(arr,mid+1,right);
        int max = Math.max(leftmax,rightMax);
        return max;
    }
    public static void main(String [] args){
        int[] arr = {1,4,3,2};
        int temp = getMax(arr,0,arr.length-1);
        System.out.println(temp);
    }
}
